package com.dylan.channel.v9;

import com.dylan.channel.v9.channel.Channel;
import com.dylan.channel.v9.future.ChannelFuture;
import com.dylan.channel.v9.future.ChannelPromise;
import com.dylan.channel.v9.future.DefaultChannelPromise;

import java.nio.channels.Selector;


public abstract class SingleThreadEventLoop extends SingleThreadEventExecutor implements EventLoop {

    @Override
    public ChannelFuture register(Channel channel) {
        ChannelPromise channelPromise = new DefaultChannelPromise(channel);
        return register(channelPromise);
    }

    @Override
    public ChannelFuture register(ChannelPromise promise) {
        promise.channel().unsafe().register(this, promise);
        return promise;
    }


    protected abstract Selector getSelect();

    @Override
    public EventLoop next() {
        return this;
    }

}
